﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Assignment3
{
    public class Floor : BasicShape
    {
        public Floor(Vector3 size, Vector3 position)
            : base(size, position) 
        {
            this.world = Matrix.CreateRotationX(MathHelper.ToRadians(90.0f));
        }

        public override void BuildShape()
        {
            primitiveCount = 2;
            vertices = new VertexPositionNormalTexture[6];

            Vector2[] texCoords = new Vector2[6];

            texCoords[0] = new Vector2(0, 0);
            texCoords[1] = new Vector2(0, 1);
            texCoords[2] = new Vector2(1, 0);

            texCoords[3] = new Vector2(0, 1);
            texCoords[4] = new Vector2(1, 1);
            texCoords[5] = new Vector2(1, 0);

            Vector3[] face = new Vector3[6];
            //TopLeft
            face[0] = new Vector3(-size.X, size.Y, 0.0f);
            //BottomLeft
            face[1] = new Vector3(-size.X, -size.Y, 0.0f);
            //TopRight
            face[2] = new Vector3(size.X, size.Y, 0.0f);
            //BottomLeft
            face[3] = new Vector3(-size.X, -size.Y, 0.0f);
            //BottomRight
            face[4] = new Vector3(size.X, -size.Y, 0.0f);
            //TopRight
            face[5] = new Vector3(size.X, size.Y, 0.0f);

            //face
            for (int i = 0; i <= 2; i++)
            {
                vertices[i] = new VertexPositionNormalTexture(face[i] + Vector3.UnitZ * size.Z + position, Vector3.UnitZ, texCoords[i]);
                vertices[i + 3] = new VertexPositionNormalTexture(face[i + 3] + Vector3.UnitZ * size.Z + position, Vector3.UnitZ, texCoords[i + 3]);
            }
        }

    }
}
